package io.kiki.sba.registry.server.clientInterface.remoting.console.handler;

import io.kiki.sba.registry.api.Channel;
import io.kiki.sba.registry.common.model.GenericResponse;
import io.kiki.sba.registry.common.model.sessionserver.PubSubDataInfoIdRequest;
import io.kiki.sba.registry.common.model.sessionserver.PubSubDataInfoIdResp;
import io.kiki.sba.registry.server.clientInterface.store.FetchPubSubDataInfoIdService;
import org.springframework.beans.factory.annotation.Autowired;


public class PubSubDataInfoIdRequestHandler extends AbstractConsoleHandler<PubSubDataInfoIdRequest> {

    @Autowired
    protected FetchPubSubDataInfoIdService fetchPubSubDataInfoIdService;

    @Override
    public Class interest() {
        return PubSubDataInfoIdRequest.class;
    }

    @Override
    public GenericResponse<PubSubDataInfoIdResp> doHandle(Channel channel, PubSubDataInfoIdRequest request) {
        PubSubDataInfoIdResp pubSubDataInfoIdResp = fetchPubSubDataInfoIdService.queryByIps(request.getIps());
        return new GenericResponse<PubSubDataInfoIdResp>().fillSucceed(pubSubDataInfoIdResp);
    }

    @Override
    public Object buildFailedResponse(String msg) {
        return new GenericResponse<PubSubDataInfoIdResp>().fillFailed(msg);
    }
}
